#############################################################################################
#                                                                                           #
#                   Copyright 2010-2013 Ning, Inc.                                          #
#                   Copyright 2014 Groupon, Inc.                                            #
#                   Copyright 2014 The Billing Project, LLC                                 #
#                                                                                           #
#      The Billing Project licenses this file to you under the Apache License, version 2.0  #
#      (the "License"); you may not use this file except in compliance with the             #
#      License.  You may obtain a copy of the License at:                                   #
#                                                                                           #
#          http://www.apache.org/licenses/LICENSE-2.0                                       #
#                                                                                           #
#      Unless required by applicable law or agreed to in writing, software                  #
#      distributed under the License is distributed on an "AS IS" BASIS, WITHOUT            #
#      WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the            #
#      License for the specific language governing permissions and limitations              #
#      under the License.                                                                   #
#                                                                                           #
#############################################################################################


#
#                       DO NOT EDIT!!!
#    File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
#


module Killbill
  module Plugin
    module Model

      java_package 'org.killbill.billing.catalog.api'
      class PlanPhasePriceOverride

        include org.killbill.billing.catalog.api.PlanPhasePriceOverride

        attr_accessor :phase_name, :plan_phase_specifier, :currency, :fixed_price, :recurring_price

        def initialize()
        end

        def to_java()
          # conversion for phase_name [type = java.lang.String]
          @phase_name = @phase_name.to_s unless @phase_name.nil?

          # conversion for plan_phase_specifier [type = org.killbill.billing.catalog.api.PlanPhaseSpecifier]
          @plan_phase_specifier = @plan_phase_specifier.to_java unless @plan_phase_specifier.nil?

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          @currency = Java::org.killbill.billing.catalog.api.Currency.value_of( @currency.to_s ) unless @currency.nil?

          # conversion for fixed_price [type = java.math.BigDecimal]
          if @fixed_price.nil?
            @fixed_price = java.math.BigDecimal::ZERO
          else
            @fixed_price = java.math.BigDecimal.new(@fixed_price.to_s)
          end

          # conversion for recurring_price [type = java.math.BigDecimal]
          if @recurring_price.nil?
            @recurring_price = java.math.BigDecimal::ZERO
          else
            @recurring_price = java.math.BigDecimal.new(@recurring_price.to_s)
          end
          self
        end

        def to_ruby(j_obj)
          # conversion for phase_name [type = java.lang.String]
          @phase_name = j_obj.phase_name

          # conversion for plan_phase_specifier [type = org.killbill.billing.catalog.api.PlanPhaseSpecifier]
          @plan_phase_specifier = j_obj.plan_phase_specifier
          @plan_phase_specifier = Killbill::Plugin::Model::PlanPhaseSpecifier.new.to_ruby(@plan_phase_specifier) unless @plan_phase_specifier.nil?

          # conversion for currency [type = org.killbill.billing.catalog.api.Currency]
          @currency = j_obj.currency
          @currency = @currency.to_s.to_sym unless @currency.nil?

          # conversion for fixed_price [type = java.math.BigDecimal]
          @fixed_price = j_obj.fixed_price
          @fixed_price = @fixed_price.nil? ? 0 : BigDecimal.new(@fixed_price.to_s)

          # conversion for recurring_price [type = java.math.BigDecimal]
          @recurring_price = j_obj.recurring_price
          @recurring_price = @recurring_price.nil? ? 0 : BigDecimal.new(@recurring_price.to_s)
          self
        end

      end
    end
  end
end
